
package com.dao;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.entity.UserEntity;
import org.apache.ibatis.annotations.Select;

/**
 * 用户
 */
@Mapper
public interface UserDao extends BaseMapper<UserEntity> {
	
	List<UserEntity> selectListView(@Param("ew") Wrapper<UserEntity> wrapper);

	List<UserEntity> selectListView(Pagination page,@Param("ew") Wrapper<UserEntity> wrapper);

	@Select("select role from users where id = #{id}")
    String getUserPermissions(String userId);

	@Select("select * from token where token = #{accessToken}")
	UserEntity queryByToken(String accessToken);

	@Select("SELECT id, username, password, role, addtime, status FROM users WHERE id = #{userId}")
	UserEntity queryUser(Long id);

	@Select("SELECT id, username, password, role, addtime, status FROM users WHERE username = #{username} " +
			"and role = #{role}")
	UserEntity selectByUsername(String username, String role);

	@Select("select role from users where username = #{username}")
	String getRoleByUsername(String username);

	@Select("select * from users where username = #{username}")
	UserEntity getByUsername(String username);
}
